package com.cunjin.notice.comtroller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cunjin.base.controller.BaseController;
import com.cunjin.notice.entity.NoticeEntity;
import com.cunjin.notice.service.NoticeService;

@Controller
@RequestMapping("/notice")
public class NoticeComtroller extends BaseController<NoticeEntity> {

	
	@Autowired
	private NoticeService service;


	/**
	 * 分页
	 * @param page
	 * @param rows
	 * @param searchName
	 * @return
	 */
	@RequestMapping("/findWithPage")
	@ResponseBody
	public Map<String, Object>  findWithPage(int page,int rows,String searchName) {
	
		Map<String, Object>  fy = service.queryByPage(page,rows,searchName);
		return fy;
	}
	
	/**
	 * 添加
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("/addNotice")
	@ResponseBody
	public Map<String, Object> addNotice(NoticeEntity entity) {
		
		Map<String, Object>  map = service.insert(entity);
				return map;
	}
	
	
	/**
	 * 
	 * 删除
	 * @param dles
	 * @return
	 */
	@RequestMapping("/delNotice")
	@ResponseBody
	public Map<String, Object>  delNotice(String dles) {
		
		String[] split = dles.split(",");
		Map<String, Object>  mydelete = service.deleteByids(split);
		return mydelete;
	}

	/**
	 * 更新
	 * @param entity
	 * @return
	 */
	@RequestMapping("/updateNotice")
	@ResponseBody
	public Map<String, Object>  updateNotice(NoticeEntity entity) {
		
		Map<String, Object>  myupdate = service.update(entity);
		return myupdate;
	}
	
}